#ifndef QLANGUAGEMANAGERVIEW_H
#define QLANGUAGEMANAGERVIEW_H

#include <QWidget>


#include <QTreeWidget>
#include <QItemDelegate>

namespace CORELIB
{
    class StyledBar;
}

class QLanguageManagerView;

class QLanguageDelegate: public QItemDelegate
{
    Q_OBJECT
public :
    QLanguageDelegate(QLanguageManagerView* view):m_view(view){}
    QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;

protected:
    QLanguageManagerView    *m_view;
};

class QLanguageManagerView : public QWidget
{
    Q_OBJECT
public:
    explicit QLanguageManagerView(QWidget *parent = 0);

    bool    pagePosition(const QVariant& param);

    void    make_page_position(QVariant &info);
    void    set_page_position(const QVariant &info);
signals:
    void    need_make_page_position();
protected:
    void    addLanguageItem(QObject* obj);
    void    insertLanguageItem(int index,QObject* obj);
    void    updateNo();
    bool    eventFilter(QObject *, QEvent *);
signals:

public slots:
    void    cammand_rename();
    void    cammand_property();
protected slots:
    void    addLanguage();
    void    delLanguage();
    void    itemUp();
    void    itemDown();

    void    load();
    void    clear();

    void    cammand_add();
    void    cammand_remove();
protected:
    friend class QLanguageDelegate;
protected:
    QTreeWidget         *m_languageList;
    CORELIB::StyledBar  *m_styledBar;
    QMap<QObject*,QTreeWidgetItem*>  m_items;
    QVariant            m_page_position;
};

#endif // QLANGUAGEMANAGERVIEW_H
